package com.lrm.blog.interceptor;

import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @PROJECT_NAME: blog
 * @DESCRIPTION:
 * @USER: "Wang Hong"
 * @DATE: 2022/8/14 20:09
 */
//@Deprecated
public class LoginInterCeptor implements HandlerInterceptor {

    @Override
    public boolean preHandle(HttpServletRequest request,
                             HttpServletResponse response,
                             Object handler) throws Exception {
        if (request.getSession().getAttribute("user")==null) {
            response.sendRedirect("/admin");
            return false;
        }

        return true;
    }
}
